package com.cheer.dto;

import com.cheer.entity.Applicant;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
@Accessors(chain = true)
public class ApplicantContactUpdateDTO {

    @NotNull(message = "集体Id不能为空")
    private Long applicantId;

    @NotBlank(message = "集体负责人不能为空")
    @Length(max = 20, message = "集体负责人不能超过20个字符")
    private String contactPerson;

    @NotBlank(message = "集体负责人电话不能为空")
    @Length(max = 20, message = "集体负责人电话不能超过20个字符")
    private String contactPersonPhone;

    @Length(max = 20, message = "集体电话不能超过20个字符")
    private String phone;

    @Length(max = 50, message = "邮箱不能超过50个字符")
    private String email;

    @NotBlank(message = "地址不能为空")
    @Length(max = 200, message = "地址不能超过200个字符")
    private String address;

    public Applicant build() {
        Applicant applicant = new Applicant();
        applicant.setId(applicantId);
        applicant.setContactPerson(contactPerson);
        applicant.setContactPersonPhone(contactPersonPhone);
        applicant.setPhone(phone);
        applicant.setEmail(email);
        applicant.setAddress(address);
        return applicant;
    }
}
